package com.datastructure.test.jumpgame;

public class JumpGame {

    public static void main(String[] args) {

    }

    public boolean canJump (int[] nums) {
        // write code here
        int end = 0;
        for (int i = 0; i < nums.length; i++) {
            if (i > end) {
                return false;
            }
            end = Math.max(end, i + nums[i]);
            if (end >= nums.length - 1) {
                return true;
            }
        }
        return false;
    }
}
